package com.javaee.jie;

import com.javaee.jie.mapper.UserMapper;
import com.javaee.jie.po.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    @Test
    public void test()  throws IOException {
        String resource="mybatis-config.xml";

        InputStream is= Resources.getResourceAsStream(resource);

        SqlSessionFactory sqlSessionFactory= new SqlSessionFactoryBuilder().build(is);

        SqlSession session= sqlSessionFactory.openSession();

        UserMapper mapper = session.getMapper(UserMapper.class);

        User user = new User("admin","123456","123","123");

        mapper.addUser(user);

        mapper.selectUser("杰");
        mapper.selectUsers();
        session.commit();


    }
}
